#ifndef __QTASK__H__
#define __QTASK__H__
#define QT_PATH_MAX     256
#define QT_TASKS_MAX    256
#define QT_NAME_MAX     128
#define QT_TASK_TOP     0x01
typedef struct _XTASK
{
    int  status;
    int  qhead;
    int  queue;
    int  wait;
    char name[QT_NAME_MAX];
}XTASK;
/* FILE IO */
typedef struct _QTIO
{
    int     fd;
    void    *map;
    off_t   end;
    off_t   size;
}QTIO;
typedef struct _QTSTATE
{
    int qtasks;
    XTASK tasks[QT_TASKS_MAX];
}QTSTATE;
typedef struct _QTASK
{
    int log_access;
    void *mutex;
    void *logger;
    void *map;
    void *qhead;
    void *queue;
    void *wait;
    QTSTATE *state;
    QTIO stateio;
    char basedir[QT_PATH_MAX];
}QTASK;
QTASK *qtask_init(char *basedir);
int qtask_add_task(QTASK *qtask, char *name);
int qtask_rename_task(QTASK *qtask, int taskid, char *name);
int qtask_del_task(QTASK *qtask, int taskid);
int qtask_list_tasks(QTASK *qtask, char *out, char *end);
int qtask_push_task(QTASK *qtask, int taskid, int flag, int64_t dataid);
int64_t qtask_pop_task(QTASK *qtask, int taskid);
int qtask_retask(QTASK *qtask, int taskid, int64_t id);
void qtask_clean(QTASK *qtask);
#endif
